package com.lancoo.klgcourseware.utils;

import android.net.Uri;


/**
 * Created by pengmi on 2018/7/5.
 * Description: 中文字符编码工具类
 */

public class KlgUrlEncodeUtils {

    /**
     * url格式转换,对中文字符编码
     * @param url 音频url
     * @return
     */
//    public static String urlencodChange(String url){
//        if (TextUtils.isEmpty(url)) {
//            return "";
//        }
//        StringBuffer sbUrl=new StringBuffer();
//        String[] ips = url.split(":");
//        for (int i = 0; i < ips.length-1; i++) {
//            sbUrl.append(ips[i]);
//            sbUrl.append(":");
//        }
//        String[] split = ips[ips.length-1].split("/|\\\\");
//        for (int i = 0; i < split.length; i++) {
//            if(!TextUtils.isEmpty(split[i])){
//                sbUrl.append( Uri.encode(split[i].replace("+","\\+")));
//                sbUrl.append("/");
//            }
//        }
////        for (int i = 0; i < split.length; i++) {
////            url=url.replaceFirst(split[i].replace(".","\\.").replace("[","\\[").replace("]","\\]"), Uri.encode(split[i]));
////            Log.e("aaaa",split[i]+":"+ Uri.encode(split[i]));
////        }
//        Log.e("url","url"+url);
//        return sbUrl.toString().substring(0,sbUrl.toString().length()-1).replace("%5C%2B","+");
//    }

    public static String urlencodChange(String url){
        return Uri.encode(url,"-![.:/,%?&=\\]");
    }
}
